package com.example.module_web.view.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.example.module_web.R;
import com.example.module_web.adapter.BuyerAdapter;
import com.example.module_web.base.BaseFragmentB;
import com.example.module_web.beans.Buyer;
import com.example.module_web.viewmodule.NetData_Web;

import java.util.List;

/**
 * Created by Administrator on 2018/2/20.
 */

public class Fragment_10 extends FormFragment {
    private static final String TAG = "bug";
    private RecyclerView mRecyBuyer;
    private List<Buyer> mBuyers;

    @Override
    protected int setLayoutId() {
        return R.layout.web_fragment_10;
    }
    @Override
    protected void initView(View view) {
        mRecyBuyer = view.findViewById(R.id.web_frag10_recy_buyer);
    }

    @Override
    protected void initEvent(Context context, Bundle savedInstanceState) {
        setupRecyclerData(context);
    }


    public void setupRecyclerData(Context context) {
        setupRecycler(context,mRecyBuyer);
        loadNetData(context);
    }

    private void loadNetData(final Context context) {
        NetData_Web.getInstance().getBuyers(context, "Buyer", new NetData_Web.Singer<List<Buyer>>() {
            @Override
            public void success(List<Buyer> buyers) {
                Log.e(TAG, "success: buyers"+buyers);
                mBuyers = buyers;
                BuyerAdapter buyerAdapter = new BuyerAdapter(context, buyers);
                mRecyBuyer.setAdapter(buyerAdapter);
            }
            @Override
            public void failed(String s) {

            }
        });
    }
}
